home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / System / Chassis 6.0 ƒ / WhichWindow.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-22  |  1.6 KB  |  36 lines  |  [TEXT/KAHL]

  1. /************************************************************************************/
  2. /*    WhichWindow                                                                        */
  3. /*    This routine matches a WindowPtr with an entry in the window table windTbl,    */
  4. /*  returning the subscript of the entry.  Return code is one if a match is not        */
  5. /*  found and zero if a match is found.                                                */
  6. /*      If a NIL window pointer is passed into this routine, the result is the same    */
  7. /*    as if the front window had been found to match.  This is in case the front        */
  8. /*    window has been hidden and there are no other windows active.  The FrontWindow    */
  9. /*    function would have returned NIL, which would have been passed here.  We would    */
  10. /*    still want to use the front window's record, even though the window is hidden.    */
  11. /************************************************************************************/
  12.  
  13. #include "MyHeaders.h"
  14.  
  15. short WhichWindow(WindowPtr WhichWindPtr, short * WhichSubscript)
  16. {
  17.     short    WhichWindRetCode = 1;                /* default return code is bad        */
  18.  
  19.     if (WhichWindPtr == NIL)
  20.         {                                        /* if FrontWindow returned NIL        */
  21.         *WhichSubscript = 0;                    /*   point to main window rec        */
  22.         WhichWindRetCode = 0;                    /*   set return code to good        */
  23.         goto ENDING;                            /*   get out                        */
  24.         }
  25.     
  26.     for (j=0; j<windMax; j++)                    /* check the table for..             */
  27.         if (WhichWindPtr == windTbl[j].windPtr)    /* ..a match with pointer            */ 
  28.             {                                    /* if there is a hit..                */
  29.             *WhichSubscript = j;
  30.             WhichWindRetCode = 0;                /*   set return code to good        */
  31.             break;                                /*   get out of the loop            */
  32.             }
  33.  
  34. ENDING:
  35.     return WhichWindRetCode;
  36. }